﻿using System.Collections;
using UnityEngine;
using UnityEngine.UI;
using shaco.ActionExtensions;

[shaco.UILayerCustomPrefabPath(ShootMan.GlobalDefines.UIPath.TIP_LAYER)]
[shaco.UILayerIndex((int)ShootMan.GlobalDefines.UILayers.Default)]
[shaco.UILayerOpenAsync]
public class TipLayer : UnityEngine.MonoBehaviour, shaco.IUIAnimation
{
    public class OpenUIArg : shaco.Base.BaseEventArg
    {
        public string content = string.Empty;
    }

    public Text textContent;
    public Button buttonConfirm;

    void OnUIOpen(OpenUIArg arg)
    {
        this.textContent.text = arg.content.ToString();
        this.buttonConfirm.onClick.AddListener(this.OnClickConfirm);
    }

    void OnClickConfirm()
    {
        this.CloseMe();
    }

    public IEnumerator RunUIOpenAnimation()
    {
        shaco.GameHelper.sound.Play($"{ShootMan.GlobalDefines.HOTUPDATE_ROOT}Audio/ui_show.wav");
        yield return this.ScaleTo(new Vector3(0.1f, 0.1f, 0.1f), 0).ScaleTo(Vector3.one, 0.3f);
    }

    public IEnumerator RunUICloseAnimation()
    {
        shaco.GameHelper.sound.Play($"{ShootMan.GlobalDefines.HOTUPDATE_ROOT}Audio/ui_hide.wav");
        yield return this.ScaleTo(Vector3.one, 0).ScaleTo(new Vector3(0.1f, 0.1f, 0.1f), 0.3f);
    }

    public void OnUIAnimationBreak()
    {
    }
}